//
// Created by 17775 on 2024/10/30.
//

#ifndef RAYCI_DIVERGENCE_H
#define RAYCI_DIVERGENCE_H

#include "RayCiPro_C.h"
#include <thread>
#include <atomic>
#include <QObject>
#include <windows.h>
#include <shellapi.h>

struct DivergenceResult {
    int dCount = 0;
    double dDivergenceUX = 0;
    double dDivergenceUY = 0;
    double dZeroPointUX = 0;
    double dZeroPointUY = 0;
    double dDivergenceUncertaintyUX = 0;
    double dDivergenceUncertaintyUY = 0;
    double dZeroPointUncertaintyUX = 0;
    double dZeroPointUncertaintyUY = 0;
};

class Divergence : public QObject{

Q_OBJECT

signals:
    void divergenceMeasurementOver();

public slots:
    void exportReport();

public:
    int _iDivergenceDocId = 0;

    void stopDivergence() const;
    void stopDivergenceThread();

    std::thread m_divergenceThread;
    std::atomic<bool> getDivergenceDataThreadRunning = true;
    void clearDivergence() const;
    void setFrameSpan(int frames) const;
    void setSingleShot(bool bEveryFrame) const;
    void setTimeSpan(double dTime) const;

//    void getData();
//    void getAllData();

    // Recording
    QString getRecordingRemark() const;
    void setPosition(double dPosition) const;

    // Sequence
    int getCurrentItem() const;
    int getItemCount() const;
    void setCurrentItem(int index) const;
    QString getItemInfo(int index) const;

    // Analysis
    DivergenceResult getDivergenceResult() const;

    // Divergence
    void close(bool bWaitWhileClosing);
};


#endif //RAYCI_DIVERGENCE_H
